
#pragma once
#include <string>
#include <vector>

#include "Utils.h"

using namespace std;

/*
Manage = tcp://127.0.0.1:3306,root,123, Nx_Manage
Role = tcp://127.0.0.1:3306,root,123, Nx_Role
Family = tcp://127.0.0.1:3306,root,123, Nx_Family
Master = tcp://127.0.0.1:3306,root,123, Nx_Mas
*/

struct DBConnect
{
public:
    DBConnect()
    {
        Proc_Manage = 0;
        Proc_Role = 0;
        Proc_Family = 0;
        Proc_Master = 0;

        Proc_Mail = 0;

        role_id_max = 0;
    }

    bool IsConfigLoaded()
    {
        return ( Manage.size() > 0 && Role.size() > 0 && Family.size() > 0  && Master.size() > 0 && Mail.size() > 0 );
    }

    string  Manage;
    string  Role;
    string  Family;
    string  Master;

    string Mail;

    int  Proc_Manage;
    int  Proc_Role;
    int  Proc_Family;
    int  Proc_Master;

    int  Proc_Mail;

    int role_id_max;
};

class ConfigChecker : public CriticalObject
{
public:
        ConfigChecker();
        ~ConfigChecker();

public:
        bool LoadConfig();
        bool CheckDBConnStr();
        bool CheckDBConnection();
        void PrintConfig();

public:
        DBConnect master;
        vector<DBConnect>  slaves;

        // 用于记录
};

extern ConfigChecker* _CONFIG;
extern CAsyncProcMgr* _PROC;
